package com.annotationApplicationContext.ch03;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * bean 后置处理器
 */
@Slf4j
@Component
public class Student implements BeanPostProcessor {

    public Student() {
        log.debug(" create Student");
    }

    //在任何bean初始化之前，比如InitializingBean's {@code afterPropertiesSet} 等都属于init方法
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        log.debug(" postProcessBeforeInitialization");
        return bean;
    }

    //在任何bean初始化之后
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        log.debug(" postProcessAfterInitialization");
        return bean;
    }
}
